layui.use(['form', 'layedit', 'laydate'], function(){
  var form = layui.form
  ,laydate = layui.laydate
  ,layer = layui.layer
  ,layedit = layui.layedit;

	var state = $("#shenhe").val();
	
	/*alert(getParameter("id"));*/
	
	$("#sub").click(function(){
		//加载层
		var index = layer.load(0, {
			  shade: [0.1,'#fff'] //0.1透明度的白色背景
			});
		if($("#audit").val()==""){
			layer.msg('未做审核操作', {icon: 2}); 
		}else if($("#auditCause").val()==""){
			layer.msg('审核意见不能为空', {icon: 2}); 
		}else if($("#audit").val()==2){
			var url = "../../listenBranchWholesale/financeAudit.action";
			var date = {"bwId":getParameter("id"),"bwStatusString":$("#audit").val(),"auditingExplain":$("#auditCause").val()};
			$.post(url,date,function(mes){
						if(mes.datas == 1){
							parent.layer.msg(mes.msg,function(){
								icon:2;
							});
                            parent.location.href="../../pages/wholesalesAudit/wholAudit.html";
						}else{
							 layer.msg("库存不足",{time:2000});
						}
			},"json")
		}else if($("#audit").val()==4){
			var url = "../../listenBranchWholesale/financeAudits.action";
			var date ={"bwId":getParameter("id"),"bwStatusString":$("#audit").val(),"auditingExplain":$("#auditCause").val()};
			$.post(url,date,function(mes){
				if(mes.datas ==1){
					/*alert("审核未通过");*/
					parent.layer.msg(mes.msg,function(){
						icon:2;
					});
                    parent.location.href="../../pages/wholesalesAudit/wholAudit.html";
				}
			},"json")
		}
	})
	
	
  
  
});


layui.use('upload', function(){
	  var $ = layui.jquery
	  ,upload = layui.upload;
});
function load(){
	var form = layui.form;
	form.render();
}

/**
 * 从地址栏传值的代码
 * @param param
 * @returns
 */
function getParameter(param){
	var query = window.location.search;
	var iLen = param.length;
	var iStart = query.indexOf(param);
	if (iStart == -1)
		return "";
	iStart += iLen + 1;
	var iEnd = query.indexOf("&", iStart);
	if (iEnd == -1)
		return query.substring(iStart);
	return query.substring(iStart, iEnd);
}